
rivers = {
  "London": "Thames", 
  "Leeds": "Aire", 
  "Liverpool": "Mersey",
  "York": "Ouse"
}

# loop through the dict extracting key and value

print("1. Iterate through both keys (city) and values (river):")
for city, river in rivers.items():
    print(f"City: {city}, River: {river}")
    
# create 2 further for loops to iterate: 1. just through the keys, 2. just through the values
print("\n2. Iterate through only keys (cities):")
for city in rivers.keys():  # .keys() 方法返回字典中所有键的集合
    print(f"City: {city}")

# hint: we looked at built in function for dicts last session
print("\n3. Iterate through only values (rivers):")
for river in rivers.values():  # .values() 方法返回字典中所有值的集合
    print(f"River: {river}")